<template>
<h1>双向绑定指令</h1>
  <h3>用户注册</h3>
  用户名：<input type="text" placeholder="请输入用户名" v-model="user.username"><br>
  密码：<input type="password" placeholder="请输入密码" v-model="user.password">
  性别：<input type="radio" name="sex" v-model="user.gender">男
  <input type="radio" name="sex" v-model="user.gender">女
  <br>
  <button @click="reg">注册</button>
</template>

<script setup>
import {ref} from "vue";
//定义对象用来保存注册表单中的数据
const user=ref({
  username:'baby',
  password:'666',
  gender:'0'
});
const reg=()=>{
  console.log(user.value);
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.gender);
};
</script>

<style scoped>

</style>